//
//  XMMeetBoxViewController.m
//  XMJJ_zml
//
//  Created by 丁浩 on 2025/5/27.
//

#import "XMMeetBoxViewController.h"
#import "XMMeetBoxView.h"
#import "XMNetwork+mine.h"
#import "XMNetwork+home.h"
#import "XMConfirmOrderViewController.h"
#import "XMMeetBoxModel.h"

@interface XMMeetBoxViewController ()<XMMeetBoxViewDelegate>

@property (nonatomic, strong) XMMeetBoxView *meetBoxView;

@end

@implementation XMMeetBoxViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self creatUI];
}

- (void)creatUI {
    [self.view addSubview:self.meetBoxView];
    [self getMyMeetBox];
}

- (void)getMyMeetBox {
    XMWeakSelf;
    [_Network getMyMeetBoxSuccess:^(id  _Nonnull responseObject) {
        NSArray *meetBoxModelArr = [NSArray yy_modelArrayWithClass:[XMMeetBoxModel class] json:[responseObject safeArrayForKey:@"data"]];
        [weakSelf.meetBoxView setContentWithBoxModelArr:meetBoxModelArr];
    } failure:^(NSError * _Nonnull error) {
        
    }];
}

//删除见面
- (void)meetDeleteWithCartIds:(NSString *)cartIds {
//    NSLog(@"删除见面");
    XMWeakSelf;
    [_Network myMeetBoxDeleteMeetWithCartIds:cartIds success:^(id  _Nonnull responseObject) {
        [weakSelf getMyMeetBox];
    } failure:^(NSError * _Nonnull error) {

    }];
}

////创建订单
//- (void)creatOrderWithCartIds:(NSString *)cartIds {
//    XMWeakSelf;
//    [_Network creatOrderWithCartIds:cartIds
//                          addressId:@""
//                            payType:@"1"
//                            success:^(id  _Nonnull responseObject) {
//        XMConfirmOrderViewController *confirmOrderVC = [[XMConfirmOrderViewController alloc] init];
//        [weakSelf.navigationController pushViewController:confirmOrderVC animated:YES];
//    } failure:^(NSError * _Nonnull error) {
//
//    }];
//}

//去首页逛逛
- (void)goHomeAction {
    [self.navigationController popToRootViewControllerAnimated:NO];
    self.tabBarController.selectedIndex = 0;
}

//确认选择
- (void)settleWithSelectServiceModelArr:(NSArray *)selectServiceModelArr
                           selectRowDic:(nonnull NSDictionary *)selectRowDic {
    XMConfirmOrderViewController *confirmOrderVC = [[XMConfirmOrderViewController alloc] init];
    confirmOrderVC.meetBoxModelArr = selectServiceModelArr;
    confirmOrderVC.selectRowDic = selectRowDic;
    [self.navigationController pushViewController:confirmOrderVC animated:YES];
}

#pragma mark - Init
- (XMMeetBoxView *)meetBoxView {
    if (!_meetBoxView) {
        _meetBoxView = [[XMMeetBoxView alloc] initWithFrame:self.view.bounds];
        _meetBoxView.delegate = self;
    }
    return _meetBoxView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
